/** ###################################################################
**     Filename  : ad.C
**     Project   : ad
**     Processor : 56F8013VFAE
**     Version   : Driver 01.14
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 2012-3-24, 16:39
**     Abstract  :
**         Main module.
**         This module contains user's application code.
**     Settings  :
**     Contents  :
**         No public methods
**
** ###################################################################*/
/* MODULE ad */


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "Term1.h"
#include "Inhr1.h"
#include "AD1.h"
#include "TI1.h"
#include "PWM1.h"
#include "PWM2.h"
#include "EInt1.h"
#include "EInt2.h"
#include "EInt3.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

word *Val;
int flag;
uint8_t *ch;

void main(void)
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
AD1_Enable();
AD1_Start();

 flag=0;
 *ch='0';
  for(;;) {
  
// Term1_ReadChar(ch);


    if(*ch=='1')
    {
       flag=1;
    }
    if(*ch=='3')
    {
       flag=0;	
    }
    if(*ch=='2')
    {
      flag=2;	
    }
    
     if(flag==1)
    {
    	PWM1_SetRatio16(*Val);
    	PWM2_SetRatio16(0);
    }
    else if(flag==2)
    {
    	PWM1_SetRatio16(0);
    	PWM2_SetRatio16(*Val);    	
    }
    else
    {
    	PWM1_SetRatio16(0);
        PWM2_SetRatio16(0);
    }      
    
  }
}

/* END ad */
/*
** ###################################################################
**
**     This file was created by Processor Expert 3.00 [04.35]
**     for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
